package m.jclecai.com.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

import m.jclecai.com.R;

public class ProgressDialog extends Dialog {
    public ProgressDialog(Context context) {
        super(context, R.style.ProgressStyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.progress_dialog);
        ImageView iv_tadpole = (ImageView) findViewById(R.id.iv_tadpole);
        rotateAnimation(iv_tadpole);
    }

    public void setMessage(String message) {
        TextView tv_message = (TextView) findViewById(R.id.tv_message);
        tv_message.setText(message);
    }

    private void rotateAnimation(View v) {
        RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animation.setDuration(1000);
        animation.setRepeatCount(-1);
        v.startAnimation(animation);
    }


}
